public void translate(ClassGenerator classGen, MethodGenerator methodGen) { final Type ltype = _left.getType(); _left.translate(classGen, methodGen); if (_type.identicalTo(ltype) == false) { _left.startIterator(classGen, methodGen); ltype.translateTo(classGen, methodGen, _type); } } }
public void translate(ClassGenerator classGen, MethodGenerator methodGen) { _arg.translate(classGen, methodGen); final Type targ = _arg.getType(); if (!targ.identicalTo(Type.Boolean)) { _arg.startIterator(classGen, methodGen); targ.translateTo(classGen, methodGen, Type.Boolean); } } }
/** * Type check a call to a standard function. Insert CastExprs when needed. * If as a result of the insertion of a CastExpr a type check error is * thrown, then catch it and re-throw it with a new "this". */ public Type typeCheckStandard(SymbolTable stable) throws TypeCheckError { _fname.clearNamespace(); // HACK!!! final int n = _arguments.size(); final Vector argsType = typeCheckArgs(stable); final MethodType args = new MethodType(Type.Void, argsType); final MethodType ptype = lookupPrimop(stable, _fname.getLocalPart(), args); if (ptype != null) { for (int i = 0; i < n; i++) { final Type argType = (Type) ptype.argsType().elementAt(i); final Expression exp = (Expression)_arguments.elementAt(i); if (!argType.identicalTo(exp.getType())) { try { _arguments.setElementAt(new CastExpr(exp, argType), i); } catch (TypeCheckError e) { throw new TypeCheckError(this); // invalid conversion } } } _chosenMethodType = ptype; return _type = ptype.resultType(); } throw new TypeCheckError(this); }
/** * Type checking a cast expression amounts to verifying that the * type conversion is legal. Cast expressions are created during * type checking, but typeCheck() is usually not called on them. * As a result, this method is called from the constructor. */ public Type typeCheck(SymbolTable stable) throws TypeCheckError { Type tleft = _left.getType(); if (tleft == null) { tleft = _left.typeCheck(stable); } if (tleft instanceof NodeType) { tleft = Type.Node; // multiple instances } else if (tleft instanceof ResultTreeType) { tleft = Type.ResultTree; // multiple instances } if (InternalTypeMap.maps(tleft, _type) != null) { return _type; } // throw new TypeCheckError(this); throw new TypeCheckError(new ErrorMsg( ErrorMsg.DATA_CONVERSION_ERR, tleft.toString(), _type.toString())); }
public void translate(ClassGenerator classGen, MethodGenerator methodGen) { final InstructionList il = methodGen.getInstructionList(); Type targ; if (argumentCount() == 0) { il.append(methodGen.loadContextNode()); targ = Type.Node; } else { final Expression arg = argument(); arg.translate(classGen, methodGen); arg.startIterator(classGen, methodGen); targ = arg.getType(); } if (!targ.identicalTo(Type.String)) { targ.translateTo(classGen, methodGen, Type.String); } } }
public void translate(ClassGenerator classGen, MethodGenerator methodGen) { final InstructionList il = methodGen.getInstructionList(); Type targ; if (argumentCount() == 0) { il.append(methodGen.loadContextNode()); targ = Type.Node; } else { final Expression arg = argument(); arg.translate(classGen, methodGen); arg.startIterator(classGen, methodGen); targ = arg.getType(); } if (!targ.identicalTo(Type.Real)) { targ.translateTo(classGen, methodGen, Type.Real); } } }
public void translate(ClassGenerator classGen, MethodGenerator methodGen) { if (hasNodeSetArgs() || hasReferenceArgs()) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); // Call compare() from the BasisLibrary _left.translate(classGen, methodGen); _left.startIterator(classGen, methodGen); _right.translate(classGen, methodGen); _right.startIterator(classGen, methodGen); il.append(new PUSH(cpg, _op)); il.append(methodGen.loadDOM()); int index = cpg.addMethodref(BASIS_LIBRARY_CLASS, "compare", "(" + _left.getType().toSignature() + _right.getType().toSignature() + "I" + DOM_INTF_SIG + ")Z"); il.append(new INVOKESTATIC(index)); } else { translateDesynthesized(classGen, methodGen); synthesize(classGen, methodGen); } }
if (_select.getType() instanceof NodeSetType) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList();
Type tleft = _left.getType();
public void translateDesynthesized(ClassGenerator classGen, MethodGenerator methodGen) { final Type tleft = _left.getType(); final InstructionList il = methodGen.getInstructionList();
(_op == Operators.LT) ? Operators.GT : (_op == Operators.GE) ? Operators.LE : Operators.GE; tright = _right.getType();
public void translateDesynthesized(ClassGenerator classGen, MethodGenerator methodGen) { FlowList fl; final Type ltype = _left.getType();
if (_right.getType() instanceof IntType) { _right = new CastExpr(_right, Type.Real);
public void translate(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); final Type tselect = _select.getType();