MCPcopy Create free account
hub / github.com/crossoverJie/gscript / initClassObjectField

Method initClassObjectField

visitor.go:953–966  ·  view source on GitHub ↗

初始化 classObject 中的变量数据

(class *sym.Class, object *stack.ClassObject)

Source from the content-addressed store, hash-verified

951
952// 初始化 classObject 中的变量数据
953func (v *Visitor) initClassObjectField(class *sym.Class, object *stack.ClassObject) {
954 for _, symbol := range class.GetSymbols() {
955 switch symbol.(type) {
956 case *sym.Variable:
957 // 为 class 中的变量初始化为空值
958 object.SetValue(symbol.(*sym.Variable), nil)
959 }
960 }
961
962 // 初始化变量,比如 class X{**int a=10**}
963 ctx := class.GetCtx().(*parser.ClassDeclarationContext)
964 v.VisitClassDeclaration(ctx)
965
966}
967
968// 获取函数的 object 对象,需要用来压栈
969func (v *Visitor) getFunctionObject(ctx *parser.FunctionCallContext) *stack.FuncObject {

Callers 1

initClassObjectMethod · 0.95

Calls 4

VisitClassDeclarationMethod · 0.95
GetSymbolsMethod · 0.65
SetValueMethod · 0.65
GetCtxMethod · 0.65

Tested by

no test coverage detected