| 1034 | } |
| 1035 | |
| 1036 | func (ls *LState) initCallFrame(cf *callFrame) { // +inline-start |
| 1037 | if cf.Fn.IsG { |
| 1038 | ls.reg.SetTop(cf.LocalBase + cf.NArgs) |
| 1039 | } else { |
| 1040 | proto := cf.Fn.Proto |
| 1041 | nargs := cf.NArgs |
| 1042 | np := int(proto.NumParameters) |
| 1043 | if nargs < np { |
| 1044 | // default any missing arguments to nil |
| 1045 | newSize := cf.LocalBase + np |
| 1046 | // this section is inlined by go-inline |
| 1047 | // source function is 'func (rg *registry) checkSize(requiredSize int) ' in '_state.go' |
| 1048 | { |
| 1049 | rg := ls.reg |
| 1050 | requiredSize := newSize |
| 1051 | if requiredSize > cap(rg.array) { |
| 1052 | rg.resize(requiredSize) |
| 1053 | } |
| 1054 | } |
| 1055 | for i := nargs; i < np; i++ { |
| 1056 | ls.reg.array[cf.LocalBase+i] = LNil |
| 1057 | } |
| 1058 | nargs = np |
| 1059 | ls.reg.top = newSize |
| 1060 | } |
| 1061 | |
| 1062 | if (proto.IsVarArg & VarArgIsVarArg) == 0 { |
| 1063 | if nargs < int(proto.NumUsedRegisters) { |
| 1064 | nargs = int(proto.NumUsedRegisters) |
| 1065 | } |
| 1066 | newSize := cf.LocalBase + nargs |
| 1067 | // this section is inlined by go-inline |
| 1068 | // source function is 'func (rg *registry) checkSize(requiredSize int) ' in '_state.go' |
| 1069 | { |
| 1070 | rg := ls.reg |
| 1071 | requiredSize := newSize |
| 1072 | if requiredSize > cap(rg.array) { |
| 1073 | rg.resize(requiredSize) |
| 1074 | } |
| 1075 | } |
| 1076 | for i := np; i < nargs; i++ { |
| 1077 | ls.reg.array[cf.LocalBase+i] = LNil |
| 1078 | } |
| 1079 | ls.reg.top = cf.LocalBase + int(proto.NumUsedRegisters) |
| 1080 | } else { |
| 1081 | /* swap vararg positions: |
| 1082 | closure |
| 1083 | namedparam1 <- lbase |
| 1084 | namedparam2 |
| 1085 | vararg1 |
| 1086 | vararg2 |
| 1087 | |
| 1088 | TO |
| 1089 | |
| 1090 | closure |
| 1091 | nil |
| 1092 | nil |
| 1093 | vararg1 |