public void GenerateStoreBytecode(ClassesContainer container, ByteBlock context) { switch (InferredSymbolType) { case SymbolType.Local: Variable variable = GetTarget <Variable>(); Symbol symbol = context.SymbolTable.GetSymbol(variable.Name); context.Instructions.Add(new StoreCode(symbol.Id)); break; case SymbolType.ClassMember: Field target = GetTarget <Field>(); context.Instructions.Add(new StoreGlobalCode(container.GetClassId(target.ParentClass), target.Id)); break; case SymbolType.StructMember: target = GetTarget <Field>(); if (Expression.ParentClass == target.ParentClass) { context.Instructions.Add(new StructPushCurrent()); } context.Instructions.Add(new StructStoreMemberCode(target.Id)); break; case SymbolType.ExternalMember: throw new NotImplementedException(); default: break; } }
public override void GenerateBytecode(ClassesContainer container, ByteBlock context) { Class targetClass = container.TryGetClass(Constants.STDVectorClassName); context.Instructions.Add(new StructCreateCode(container.GetClassId(Constants.STDVectorClassName))); foreach (var element in Elements) { element.GenerateBytecode(container, context); } context.Instructions.Add(new VectCreateCode(Elements.Count)); context.Instructions.Add(new CtorCallCode(targetClass.GetCtor().Id, 1)); }
public override void GenerateBytecode(ClassesContainer container, ByteBlock context) { Class targetClass = container[CtorName]; context.Instructions.Add(new StructCreateCode(container.GetClassId(CtorName))); if (StructCtor != null) { foreach (var parameter in Parameters) { parameter.GenerateBytecode(container, context); } context.Instructions.Add(new CtorCallCode(targetClass.GetCtor().Id, Parameters.Count)); } }
public void GenerateLoadBytecode(ClassesContainer container, ByteBlock context) { if (Type == AccessorType.Field) { switch (InferredSymbolType) { case SymbolType.Local: Variable variable = GetTarget <Variable>(); Symbol symbol = context.SymbolTable.GetSymbol(variable.Name); context.Instructions.Add(new LoadCode(symbol.Id)); break; case SymbolType.ClassMember: Field target = GetTarget <Field>(); context.Instructions.Add(new LoadGlobalCode(container.GetClassId(target.ParentClass.ClassName), target.Id)); break; case SymbolType.StructMember: target = GetTarget <Field>(); if (Expression.ParentClass == target.ParentClass) { context.Instructions.Add(new StructPushCurrent()); } context.Instructions.Add(new StructLoadMemberCode(target.Id)); break; case SymbolType.ExternalMember: target = GetTarget <Field>(); context.Instructions.Add(new LoadGlobalCode(container.GetClassId(target.ParentClass.ClassName), target.Id)); break; default: break; } } else if (Type == AccessorType.Method) { Method target = GetTarget <Method>(); switch (InferredSymbolType) { case SymbolType.ClassMember: context.Instructions.Add(new MethodCallCode(container.GetClassId(target.ParentClass), target.Id)); break; case SymbolType.StructMember: if (Expression.ParentClass == target.ParentClass) { context.Instructions.Add(new StructPushCurrent()); } context.Instructions.Add(new StructCallMethodCode(target.Id)); break; case SymbolType.ExternalMember: context.Instructions.Add(new MethodCallCode(container.GetClassId(target.ParentClass), target.Id)); break; default: throw new Exception(); } } }